From: Giovanni Campagna Date: Sun, 8 Mar 2015 22:32:22 +0000 (-0700) Subject: RemoteSearch: don't complete a search that was cancelled X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~1013^2^2~1516 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=b0be6b867859cecd6d51a03a3ad92e4ca4d00ef5;p=gnome-shell.git RemoteSearch: don't complete a search that was cancelled This closes a race between setTerms and a slow GetInitialResultSet. The bug manifests as follows: - initial search for a short string - previous results === undefined, call GetInitialResultSet - user types more, cancel previous search in setTerms() - mainloop, then _gotResults([]) - previous results === [], !!previous results === true - therefore call GetSubsearchResultSet with an empty list of results - _gotResults() from GetSubsearchResultSet is empty - much later, return from GetInitialResultSet is discarded by cancellable - user unhappy because what he searched for is not there After this fix, the flow is: - initial search for a short string - previous results === undefined, call GetInitialResultSet - user types more, cancel previous search in setTerms() - mainloop, but no _gotResults - previous results === undefined, call GetInitialResultSet again with longer string - some time later, return from first GetInitialResultSet is discarded by cancellable - soon after, return from second GetInitialResultSet comes with good results - user happy https://bugzilla.gnome.org/show_bug.cgi?id=745861 --- diff --git a/js/ui/remoteSearch.js b/js/ui/remoteSearch.js index 9ab413e6f..4fc5000b8 100644 --- a/js/ui/remoteSearch.js +++ b/js/ui/remoteSearch.js @@ -236,8 +236,10 @@ const RemoteSearchProvider = new Lang.Class({ _getResultsFinished: function(results, error, callback) { if (error) { - if (!error.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED)) - log('Received error from DBus search provider %s: %s'.format(this.id, String(error))); + if (error.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED)) + return; + + log('Received error from DBus search provider %s: %s'.format(this.id, String(error))); callback([]); return; }